package com.zxct.wyserver.base;

import android.content.Context;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.zxct.wyserver.util.StatusBarUtils;

import butterknife.ButterKnife;

/**
 * Created by lanyu on 2018/1/30.
 */

public abstract class BaseFragment extends Fragment {

    protected Context context;
    private View rootView;//缓存Fragment view

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        context = getActivity();
        View view = initView();
        ButterKnife.bind(this,view);
        initDatas(view);
        return view;
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }

    @Override
    public void onResume() {
        super.onResume();
        StatusBarUtils.setTransparent(getActivity());
    }

    /**
     * 显示数据,子类选择实现该方法实现该方法
     * view 为布局视图view ,可以用此view findViewById()
     * */
    protected void initDatas(View view) {
    }

    /**初始化View视图,子类必须实现该方法*/
    protected abstract View initView() ;

    @Override
    public void onDestroy() {
        super.onDestroy();
        //检测Fragment内存泄漏
        /*RefWatcher refWatcher = MyApp.getRefWatcher(getActivity());
        refWatcher.watch(this);*/
    }
}
